
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">渠道名称</label>
    <div class="am-u-sm-9">
         <input class="am-form-field" type="text" name="channel_name" value="{$record.channel_name}" />
    </div>
</div>

<div class="am-form-group">
    <div class="am-u-sm-9 am-u-sm-push-3">
        <button type="button" class="am-btn am-btn-primary form-btn">保存修改</button>
        <button type="button" class="am-btn" onclick="history.go(-1);">取消</button>
    </div>
</div>

<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">错误信息</div>
        <div class="am-modal-bd error_msg">
            Hello world！
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>

<div class="am-modal am-modal-loading am-modal-no-btn" tabindex="-1" id="my-modal-loading">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">正在载入...</div>
        <div class="am-modal-bd">
            <span class="am-icon-spinner am-icon-spin"></span>
        </div>
    </div>
</div>
<script type="text/javascript">

    $('.form-btn').click(function(){

        var form = $(this).parents('form');
        var url = form.attr('action');
        var formData = form.serializeArray();
        $.ajax({
            url:url,
            type:'post',
            data:formData,
            dataType:'json',
            success:function(result){
                if(result.code == 0){
                    $('.am-modal-hd').text(result.message);
                    $('#my-modal-loading').modal('open');
                    timed();
                }else{
                    $('.error_msg').text(result.message);
                    $('#my-alert').modal('open');
                }
            }
        });
        return false;
    });

    function timed()
    {
        var t=setTimeout("location.href='{:url($code.'/index')}'",1000);
    }

</script>